<?php
session_start();    //启动会话
//如果未登录。没有设置Session变量“stuNo”,跳转到登录页面
if (!isset($_SESSION['stuNo'])) {
    header('Location:Login.php?frompage=Students');
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">

    <title>Document</title>
</head>

<body>
    <?php
    include 'HeaderNav.html';
    //引用数据库连接文件
    require_once 'Conn.php';
    mysqli_query($db, 'set names utf8');
    ?>
    <h1>成绩管理</h1>
    <form action="#" method="post">
        <div>
            <span>班级:</span>
            <select name="look">
                <?php
                $sqo = "SELECT * FROM class";
                if ($result = $db->query($sqo)) {
                    // 获取数据
                    while ($row = $result->fetch_assoc()) {
                        echo "<option value='" . $row["classNo"] . "'>" . $row["className"] . "</option>";
                        // echo "<option value='AA'>aaaaa</option>";
                    }
                }
                ?>
            </select>
            <span>课程:</span>
            <select name="qqq">
                <?php
                $sqp = "SELECT * FROM student, result, course WHERE student.studentID=result.studentID AND course.CourseID=result.CourseID";
                if ($result = $db->query($sqp)) {
                    // 获取数据
                    while ($row = $result->fetch_assoc()) {
                        echo "<option value='" . $row["CourseID"] . "'>" . $row["CourseName"] . "</option>";
                    }
                }
                ?>
            </select>
            <input type="submit" value="确定" name="btn">
        </div>
    </form>
    <?php
    //通过点击确定
    if (isset($_POST['btn'])) {
        $Course = $_POST["qqq"];
        $classNo = $_POST["look"];
       echo $classNo,$Course;
    };

    $sql = "SELECT * FROM student, result, course WHERE student.studentID=result.studentID AND course.CourseID=result.CourseID";
    if ($result = mysqli_query($db, $sql)) {
        echo "<table class='tb'><tr><th>学号</th><th>姓名</th><th>输入成绩</th><tr>";
        while ($row = mysqli_fetch_assoc($result)) {
            echo "<tr>" .
                "</td><td>" . $row["studentID"] .
                "</td><td>" . $row["studentName"] .
                "<td><input type='text' name='ddd[]' value=''/>" .
                "</td><tr>";
        }
        echo "</table>";
        echo "</form>";
        $result->close();
    }
    echo "<input type='submit' value='提交' name='btn'>";


    $db->close();
    ?>
    <?php
    //引用数据库连接文件
    require_once 'Conn.php';
    ?>